package singleton.type7;

/**
 * @author 龙超
 * @date 2020/7/1 16:36
 * @Description
 */
public class Singleton7 {
    public static void main(String[] args) {
        Singleton instance = Singleton.getInstance();
        Singleton instance1 = Singleton.getInstance();
        System.out.println(instance == instance1);
        System.out.println(instance.hashCode());
        System.out.println(instance.hashCode());
    }
}
class Singleton{
    private Singleton() {
    }
    private static class SingleInstance{
        private final  static Singleton INSTANCE = new Singleton();
    }
    public static synchronized Singleton getInstance(){
        return SingleInstance.INSTANCE;
    }
}
